home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / IFDEMO.MOD < prev    next >
Text File  |  1989-01-18  |  1KB  |  63 lines

  1.                                          (* Chapter 4 - Program 2 *)
  2. MODULE IfDemo;
  3.  
  4. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  5.  
  6. VAR Index1 : INTEGER;
  7.  
  8. BEGIN
  9.  
  10.    FOR Index1 := 1 TO 8 DO
  11.       IF Index1 < 4 THEN                   (* Simple IF statement *)
  12.          WriteString("Index1 is less than 4");
  13.          WriteInt(Index1,4);
  14.          WriteLn;
  15.       END;  (* end of first IF statement *)
  16.  
  17.       IF Index1 = 5 THEN                   (* two way IF statement *)
  18.          WriteString("Index1 is 5");
  19.       ELSE
  20.          WriteString("Index1 is not 5");
  21.       END;  (* end of second IF statement *)
  22.       WriteLn;
  23.  
  24.       IF Index1 = 2 THEN              (* multiple way IF statement *)
  25.          WriteString("Index1 is 2");
  26.       ELSIF Index1 = 6 THEN
  27.          WriteString("Index1 is 6");
  28.       ELSE
  29.          WriteString("I really don't care what Index1 is");
  30.       END;  (* end of third IF statement *)
  31.       WriteLn;
  32.    END;  (* of big FOR loop *)
  33.  
  34. END IfDemo.
  35.  
  36.  
  37.  
  38.  
  39. (* Result of execution
  40.  
  41. Index1 is less than 4   1
  42. Index is not 5
  43. I really don't care what Index1 is
  44. Index1 is less than 4   2
  45. Index1 is not 5
  46. Index1 is 2
  47. Index1 is less than 4   3
  48. Index is not 5
  49. I really don't care what Index1 is
  50. Index is not 5
  51. I really don't care what Index1 is
  52. Index is 5
  53. I really don't care what Index1 is
  54. Index is not 5
  55. Index1 is 6
  56. Index is not 5
  57. I really don't care what Index1 is
  58. Index is not 5
  59. I really don't care what Index1 is
  60.  
  61. *)
  62.  
  63.